Add attachments to simplepush#81033
Conversation
|
Hey there @engrbm87, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
There was a problem hiding this comment.
Can't we have the user mention "video" and "thumbnail" instead of "attachment" and "thumbnail" when adding a video under "attachments"? This way you can directly use the "attachments" key.
If I am not mistaken the "attachments" key entered by the user would be like this:
attachments:
- https://upload.wikimedia.org/wikipedia/commons/e/ee/Sample_abc.jpg
- video: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4
thumbnail: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerEscapes.jpgThere was a problem hiding this comment.
@engrbm87, thanks a lot for your review!
Your suggestion makes a lot of sense to me.
There was a problem hiding this comment.
@engrbm87 I implemented your suggestion in commit 9bc18c3e2d58eb618d594d0de244e763860200c3.
There was a problem hiding this comment.
Added a comment based on the last commit
There was a problem hiding this comment.
A better approach would be to raise an error if the attachments key values are not as per the documentation. If no errors are raised then simply use attachments=attachments_data.
for lines 85 and 86 I believe a video key should only be provided with a thumbnail. The documentation should mentions this clearly so no need to check for a video only key in the attachments.
There was a problem hiding this comment.
Thanks, makes a lot of sense.
Please see my latest commit for the implementation of your comment.
d753f4e to
4387c8d
Compare
emontnemery
left a comment
There was a problem hiding this comment.
Instead of supporting attachments which are either strings or dicts:
attachments:
- https://upload.wikimedia.org/wikipedia/commons/e/ee/Sample_abc.jpg
- video: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4
thumbnail: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerEscapes.jpgJust make them dicts always:
attachments:
- image: https://upload.wikimedia.org/wikipedia/commons/e/ee/Sample_abc.jpg
- video: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4
thumbnail: http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerEscapes.jpgThis will simplify the Python implementation and IMHO is also clearer for the user.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
emontnemery
left a comment
There was a problem hiding this comment.
LGTM, can be merged when a documentation PR has been opened
Thank you for your review! Here is a link to the documentation PR: home-assistant/home-assistant.io#26813 |
Breaking change
Proposed change
This PR adds attachments for the Simplepush component.
Attachments can be pictures, GIFs or video files defined by an URL.
I will update the documentation (https://www.home-assistant.io/integrations/simplepush/), after this PR gets merged. If preferred I can also do it beforehand.
The new functionality can be tested with the following automation:
Type of change
Additional information
Checklist
black --fast homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all..coveragerc.To help with the load of incoming pull requests: